from django.utils import simplejson

class POI:
    def __init__(self,poi):
        """constructor using models.POI"""
        self.id = poi.key().id()
        self.actions = [{'uri':'http://layar-author.appspot.com/comments?poi_id='+str(self.id),'label':'see/add comment'}]
        self.imageURL = None
        self.lat = int(poi.lat_lng.lat*1000000)
        self.lon = int(poi.lat_lng.lon*1000000)
        self.distance = None
        self.title = poi.title
        self.line2 = poi.desc1
        self.line3 = poi.desc2
        self.line4 = poi.desc3
        self.attribution = str(poi.user.user.nickname()) # use as author of POI
        self.type = 0
        self.dimenion = 1
        self.transform = {'rel':True, 'angle':0, 'scale':1.0}
        self.object = {'baseURL': "http://layar-author.appspot.com/"}    
        self.private = poi.private
    def get_dict(self):
        return self.__dict__
	def toJSON(self):
	    return simplejson.dumps(self.__dict__)
